package cn.jinjimi.app.player.impl;

import cn.jinjimi.app.player.ErrorRetry;

/**
 * Created by lforxeverc on 2017/5/18.
 */

public class DefaultErrorRetry<Player extends XrkBasePlayer> implements ErrorRetry {
    private static final int MAX_RETRY = 2;
    private int currentRetry = 0;
    private Player player;

    public DefaultErrorRetry(Player player) {
        this.player = player;
    }

    public void reset() {
        currentRetry = 0;
    }

    @Override
    public boolean onAutoRetryWhenError() {
        if (currentRetry >= MAX_RETRY) {
            return false;
        }
        currentRetry++;
        return player.retry();
    }
}
